//
//  TXSwiftFooterView.swift
//  TXiOSDemoApp
//
//  Created by xicheng on 16/11/21.
//  Copyright © 2016年 xicheng. All rights reserved.
//

import UIKit

public class TXSwiftFooterView: TXSwiftAbstractFooterView {

  private var tipsLabel:UILabel! = nil
  
  public override func prepareView() {
    tipsLabel = UILabel()
    tipsLabel.textColor = UIColor.black
    tipsLabel.font = UIFont.systemFont(ofSize: 16)
    self.addSubview(tipsLabel)
    self.configTipsLabel(WidthText:"上拉可以刷新")
    self.backgroundColor = UIColor.blue
  }
  
  
  private func configTipsLabel(WidthText text:String){
    tipsLabel.text = text
    tipsLabel.sizeToFit()
    tipsLabel.center = CGPoint(x: self.frame.width/2, y: self.frame.height/2)
  }
  
  public override func configLoadMorePullHeight() -> CGFloat {
    return 55.0
  }
  
  public override func configFooterViewStatusListener() -> ((TXSwiftFooterViewStatus) -> Void)? {
    return {
      [unowned self] (status) in
      
      switch status {
      case .normal:
        self.configTipsLabel(WidthText: "上拉可以刷新")
        break
      case .prepareToLoading:
        self.configTipsLabel(WidthText: "松开刷新数据")
        break
      case .loadingMore:
        self.configTipsLabel(WidthText: "正在加载数据中...")
        break
      case .noMoreData:
        self.configTipsLabel(WidthText: "没有更多数据了...")
      }
    
    }
  }
  
  

}
